<template>
  <div class="department" id="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav app-container-search">
        <!-- 左侧 -->
        <el-form ref="form" :model="getList" label-width="110px">
          <el-row :gutter="20">
            <el-col :span="6"
              ><el-form-item label="项目名称：">
                <el-select
                  class="selectBhz"
                  v-model="getList.fprojectid"
                  placeholder="所有项目"
                  @change="selectProject"
                >
                  <el-option
                    v-for="v in projectsObj"
                    :key="v.fItemName"
                    :label="v.fItemName"
                    :value="v.fItemValue"
                  >
                  </el-option>
                </el-select> </el-form-item
            ></el-col>
            <el-col :span="6"
              ><el-form-item label="标段名称：">
                <el-select
                  class="selectBhz"
                  v-model="getList.fCompanyid"
                  placeholder="所有标段"
                  @change="selectTender"
                >
                  <el-option
                    v-for="v in tendersObj"
                    :key="v.fItemName"
                    :label="v.fItemName"
                    :value="v.fItemValue"
                  >
                  </el-option>
                </el-select> </el-form-item
            ></el-col>

            <el-col :span="6">
              <el-form-item label="施工层位：">
                <el-select
                  v-model="getList.fConstructionhorizon"
                  placeholder="施工层位"
                  @change="yj_searchForm(getList)"
                >
                  <el-option
                    v-for="v in sgcDataList"
                    :key="v.fItemName"
                    :label="v.fItemName"
                    :value="v.fItemValue"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="混合料类型：">
                <el-select
                  class="selectBhz"
                  v-model="getList.fMixturetype"
                  placeholder="混合料类型"
                >
                  <el-option
                    v-for="v in liqhDataList"
                    :key="v.fItemName"
                    :label="v.fItemName"
                    :value="v.fItemValue"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="出料时间：">
                <el-date-picker
                  :picker-options="pickerOptions"
                  value-format="yyyy-MM-dd"
                  @change="selectTime"
                  v-model="timeDuring"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="searchBtn">
            <el-button
              type="primary"
              :loading="editLoading"
              @click="yj_searchForm(getList)"
              >查询</el-button
            >
            <el-button @click="reset">重置</el-button>
          </div>
        </el-form>
      </div>
      <div class="app-container-btn">
        <el-button type="primary" size="small" @click="yj_editForm(2)">
          查看配方
        </el-button>
        <el-button
          type="primary"
          v-if="btnPowerShow"
          size="small"
          @click="yj_editForm(0)"
        >
          新增配方
        </el-button>
        <el-button
          type="primary"
          v-if="btnPowerShow"
          size="small"
          @click="yj_editForm(1)"
        >
          编辑配方
        </el-button>
        <el-button
          type="primary"
          v-if="btnPowerShow"
          size="small"
          @click="yj_editForm(3)"
        >
          设置级配
        </el-button>
        <el-button
          type="primary"
          v-if="btnPowerShow"
          icon="el-icon-delete"
          size="small"
          @click="rowDelete(rowInfo)"
          >删除
        </el-button>
      </div>
      <!-- 表格 -->
      <div class="text_table TensionRealTime">
        <tableData
          :config="table_config"
          :dataList="tableData"
          :loading="listLoading"
          @click-change="rowChange"
          @openDialog="yj_viewForm"
          :page="getList.page"
          :pageSize="getList.pageSize"
        />
        <pagination
          :info="queryCriteriaData"
          :treelength="treelength"
          :total="queryCriteriaData.total"
          :pageNum.sync="getList.page"
          :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)"
        />
      </div>
      <messageBox
        :showMsgBox="showMsgBox"
        :msgTip="msgTip"
        :msgType="msgType"
        @confirmMsg="confirmMsg"
        @confirmMsgs="confirmMsgs"
      ></messageBox>
    </div>
  </div>
</template>
<script>
import TableData from "@/components/public/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项
// import commonPage from '@/components/pitchManage/dyMonitorManage/real_timeDataPage';//主页面列表
import messageBox from "@/components/public/messageBox"; //主页面分页
import actions from "@/actions";
import {
  getAsphaltRecipeLists, //沥青拌合站 基础设置 查询-配方管理列表页
  saveAsphaltRecipe, //沥青拌合站 基础设置 配方管理-配方保存接口
  delAsphaltRecipe, // 沥青拌合站 基础设置  删除-配方管理
  getAsphaltRecipeDetail, // 沥青拌合站 基础设置  查询-配方管理详情页
  getDictionaryTree, //字典项
  getAsphaltRecipeListByCompanyId, // 查询-沥青混合料类型下拉框
  getAsphaltRecipeSieveList, //级配列表
  saveAsphaltRecipeSieve, //级配保存
  getAsphaltRecipeSieveDetail, //级配详情
  getUserNature,
} from "@/api/request.js";

export default {
  name: "mixProportion",
  data() {
    return {
      name: "mixProportion", //按钮配置页面代号
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      },
      showMsgBox: false,
      msgTip: "请先选中数据行！",
      msgType: 1,
      timeDuring: [], //主页面日期筛选绑定值
      rowInfo: null, //当前行信息
      projectsObj: [], //项目名
      tendersObj: [],
      falgId: null,
      editLoading: false,
      iSJpSieveListBox: 0,
      table_config: formJs.table_config, // 列表配置项
      table_sieve: formJs.sieveAperture, //级配设置
      activeNames: ["0", "1", "2", "3", "4"],
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {}, //分页
      value2: "", //主页面日期筛选绑定值
      tableData: [], //表格列表数据列表
      // sieveApertureData: formJs.sieveApertureData,//级配设置
      highlightBd: true, //左侧机构树停留背景色
      treelength: false, //左侧树显示隐藏
      showName: "未选择公司",
      fId: null, //点击当前列表数据fId
      listLoading: false, //列表数据加载loading
      listsieveLoading: false, //级配设置
      loadingEditDialog: false, //弹框loading
      dialogEditVisible: false, //新增弹框是否显示
      sgcDataList: formJs.sgcDataList, //施工层位
      liqhDataList: [], //沥青混合料类型
      formData: {
        userId: "", // 当前登录用户id
        userName: "", // 当前登录用户名
        fCompanyid: "", // 当前标段id
        fCompanyname: "", // 当前标段公司name
        fId: "", // 配方fid
        fRecipenumber: "", // 配方编号
        fRecipename: "", // 配方名称
        fMixturetype: "", // 混合料类型
        fMixduration: "", //拌合时长
        fPitchnum: "", // 沥青标号
        fStandard: "", // 执行标准
        fSurfacecourse: "", // 施工部位
        fStartdates: "", // 启用时间
        fRecipedescription: "", // 描述
        fStatus: "", // 配方附件
        fAsphaltaggregateratiogoalvalue: "", // 油石比目标值
        fAsphaltaggregateratioupper: "", // 油石比上限
        fAsphaltaggregateratiolower: "", // 油石比下限
        fTemperatureupper: "", // 温度上限
        fTemperaturelower: "", // 温度下限
        fAggregate1value: "", // 骨料1目标值
        fAggregate2value: "", // 骨料2目标值
        fAggregate3value: "", // 骨料3目标值
        fAggregate4value: "", // 骨料4目标值
        fAggregate5value: "", // 骨料5目标值
        fAggregate6value: "", // 骨料6目标值
        fPowder1value: "", // 粉料1目标值
        fPowder2value: "", // 粉料2目标值
        fPowder3value: "", // 粉料总目标值
        fCementvalue: "",
        sieveList: [],
        recordfiles: [], // 删除文件id集合
      },
      sieveList: [], //级配列表数据
      formObj: formJs.formObj,
      OilStoneRate: formJs.OilStoneRate,
      temperature: formJs.temperature,
      mixingTime: formJs.mixingTime,
      mixProportion: formJs.mixProportion,
      // 列表给后端传参
      getList: {
        fprojectid: "",
        fCompanyid: "", // 施工标段id
        startDates: "", // 开始时间
        endDates: "", // 截至时间
        stationId: "", //拌合站
        machineId: "", //拌合机
        fConstructionhorizon: "", // 施工层位
        fMixturetype: "", //  沥青混合料类型
        warningLevel: "", // 预警等级
        fCloseoperation: "", //闭合状态
        page: 1, // 当前页码
        pageSize: 20, // 每页显示条数
      },
      fSourcefileList: [],

      userInfo: {}, //登录用户

      dialogTitle: "查看",
      commonData: {},
      btnShow: true, //保存按钮是否显示
      publicTable: true, //新增配方表
      rowInfo: null,
      btnPowerShow: true,

      asphaltNoList: null, //字典温度查询
      SZJP: "", //控制显示弹框内容
      JpSieveList: [], //级配时间列表
    };
  },
  components: {
    messageBox,
    TableData, //主页面列表
    Pagination, //分页
    publicForm,
    // commonPage
  },
  mounted() {
    var that = this;
    actions.onGlobalStateChange((state, prev) => {
      this.userInfo = prev.currentUser;
      this.token = prev.token;
      getUserNature({
        username: this.userInfo.loginName,
      })
        .then((res) => {
          if (res.errcode) {
            this.userInfo.companyNature = res.data.Nature;
            console.log(res.data.Nature);
            if (res.data.Nature == "总监办") {
              this.btnPowerShow = false;
            } else {
              this.btnPowerShow = true;
            }
          } else {
            // this.$message.error("获取当前用户机构性质", res.msg);
          }
        })
        .catch((err) => {
          //   this.$message.error("获取当前用户机构性质接口报错", err.msg);
          console.log("当前用户机构性质err", err);
        });
      var data = prev.currentUser.projects;
      this.projectsObj = [
        {
          fItemName: "所有项目",
          fItemValue: "",
        },
      ];
      data.map((item) => {
        this.projectsObj.push({
          fItemName: item.projectName,
          fItemValue: item.projectId,
        });
      });
    }, true);
    this.formObj[2].options = [];
    this.formObj[4].options = [];
    this.dictionaryItem("mixType", 0);
    this.dictionaryItem("asphaltNo", 1);

    this.getDate();
  },
  methods: {
    confirmMsg() {
      this.showMsgBox = false;
    },
    confirmMsgs() {
      if (this.titelName == "删除") {
        this.loading = true;
        delAsphaltRecipe({
          fId: this.rowInfo.fId,
        })
          .then((res) => {
            if (res.errcode == 0) {
              this.loading = false;
              this.showMsgBox = false;
              this.yj_searchForm(this.getList);
              this.$message.success("删除成功");
            } else {
              this.$message.error("删除失败", res.msg);
              this.loading = false;
            }
          })
          .catch(() => {
            this.loading = false;
          });
      }
    },

    selectProject(e) {
      this.falgId = e;
      this.tendersObj = [];
      this.bhzDataList = [];
      this.getList.fCompanyid = "";
      this.getList.stationId = "";
      this.getList.machineId = "";
      this.bhjDataList = [];
      // console.log(e);
      this.getTender(e);
    },
    async getTender(e) {
      await this.$http(
        " http://172.18.5.31:8300/IOTManagement/Base/Company/getGXJLBaseCompanyList.do?projectId=" +
          e,
        {
          headers: {
            "Content-Type": "application/json",
            Authorization: localStorage.getItem("access_token"),
          },
        }
      ).then((res) => {
        if (res.status == 200) {
          var data = res.data.data.GXCompanyList;
          this.tendersObj = [];
          if (data.length == 0) {
                        this.$message.warning({
                            content: "有其他人员登录此账号！",
                            duration: 1000,
                        });
                        setTimeout(() => {
                            window.location.href = "http://172.18.5.201:1080/login";
                        }, 1200);
                    } else   if (data.length == 1) {
            data.map((item) => {
              this.tendersObj.push({
                fItemName: item.sectionName,
                fItemValue: item.sectionId,
              });
            });
            this.falgId = data[0].sectionId;

            this.getList.fCompanyid = data[0].sectionId;
          } else {
            this.tendersObj = [
              {
                fItemName: "所有标段",
                fItemValue: "",
              },
            ];
            data.map((item) => {
              this.tendersObj.push({
                fItemName: item.sectionName,
                fItemValue: item.sectionId,
              });
            });
          }
        }
      });
    },
    selectTender(e) {
      console.log("标段", e);
      this.falgId = e;
      this.getList.stationId = "";
      this.getList.machineId = "";
    },
    selectStation(e) {
      this.getList.machineId = "";
      this.bhjDataList = [];
      this.getbhjDataMethods(e, 4);
    },
    // 重置按钮
    reset() {
      this.timeDuring = [];
      this.getList = {
        fprojectid: "",
        fCompanyid: "", // 施工标段id
        startDates: "", // 开始时间
        endDates: "", // 截至时间
        stationId: "", //拌合站
        machineId: "", //拌合机
        fConstructionhorizon: "", // 施工层位
        fMixturetype: "", //  沥青混合料类型
        warningLevel: "", // 预警等级
        fCloseoperation: "", //闭合状态
        page: 1, // 当前页码
        pageSize: 15, // 每页显示条数
      };
    },

    changeCollapse(e) {
      console.log(this.activeNames, e);
      return e;
    },
    // 点击当前行
    rowChange(val) {
      this.rowInfo = val;
    },
    // 新增编辑查看弹框
    yj_editForm(status) {
      if (status == 0) {
        // if (this.projectsObj.length == 2 && this.tendersObj.length == 1) {
        if (this.getList.fCompanyid != "" && this.getList.fCompanyid != null) {
          var Company = {
            fCompanyid: "",
            fCompanyname: "",
          };
          this.tendersObj.map((item) => {
            if (this.getList.fCompanyid == item.fItemValue) {
              Company = {
                fCompanyid: item.fItemValue,
                fCompanyname: item.fItemName,
              };
            }
          });
          this.$router.push({
            path: "/pitchManage/mixProportionDetail",
            query: {
              status: status,
              Company: JSON.stringify(Company),
              data: JSON.stringify(this.rowInfo),
            },
          });
        } else {
          this.msgTip = '新增配方顶部筛选"标段名称"不能为空';
          this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
          this.showMsgBox = true;
        }
        // } else {
        //   this.msgTip = "当前用户不能新增配方";
        //   this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
        //   this.showMsgBox = true;
        // }
      } else {
        if (this.rowInfo != null) {
          this.$router.push({
            path: "/pitchManage/mixProportionDetail",
            query: {
              data: JSON.stringify(this.rowInfo),
              status: status,
            },
          });
        } else {
          this.msgTip = "请先选中数据行！";
          this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
          this.showMsgBox = true;
        }
      }
    },
    // 级配列表
    getJpList() {
      var row = this.rowInfo;
      if (row != null) {
        var id = row.fId;
        this.fId = row.fId;
        this.dialogEditVisible = true;
        this.loadingEditDialog = true;
        getAsphaltRecipeSieveList({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog = false;
              this.JpSieveList = res.data.sieveList;
              console.log("JpSieveList", this.JpSieveList);
              this.getJpDetails(
                res.data.sieveList[0].fCreatedates,
                res.data.sieveList[0].fParentid
              );
            } else {
              this.msgTip = "级配列表接口报错:" + res.msg;
              this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
              this.showMsgBox = true;
            }
          })
          .catch(() => {
            console.log("级配列表接口报错");
          });
      } else {
        this.msgTip = "请先选择需要查看的数据";
        this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
        this.showMsgBox = true;
      }
    },
    JpSieveListFun(data, i) {
      this.iSJpSieveListBox = i;
      this.getJpDetails(data.fCreatedates, data.fParentid);
      // return i
    },
    // 级配详情
    getJpDetails(time, id) {
      this.loadingEditDialog = true;
      getAsphaltRecipeSieveDetail({
        fCreatedates: time, // 级配启用时间
        fParentid: id, // 配方id
      })
        .then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false;
            console.log("级配详情", res);
            var datas = res.data.asphaltRecipeSieveDetail;
            datas.map((item) => {
              if (
                item.fSieveupper != null &&
                item.fSieveupper != "" &&
                item.fSievelower != null &&
                item.fSievelower != ""
              ) {
                item.fSievemiddle =
                  (item.fSieveupper - 0 + (item.fSievelower - 0)) / 2;
              } else {
                item.fSievemiddle = "";
              }
            });
            this.sieveList = datas;
          } else {
            this.msgTip = "级配详情接口报错:" + res.msg;
            this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
            this.showMsgBox = true;
          }
        })
        .catch(() => {
          console.log("级配详情接口报错");
        });
    },
    // 获取列表数据
    yj_searchForm(data) {
      this.listLoading = true;
      window.sessionStorage.setItem(
        "GxEmbedded_pitchManage_getLists",
        JSON.stringify(data)
      );
      this.tableData = [];
      var id;
      if (data.fCompanyid != "") {
        id = data.fCompanyid;
      } else {
        id = data.fprojectid;
      }
      var sc = {
        fCompanyid: id, // 施工标段id
        startDates: data.startDates, // 开始时间
        endDates: data.endDates, // 截至时间
        stationId: "", //拌合站
        machineId: "", //拌合机
        fConstructionhorizon: data.fConstructionhorizon, // 施工层位
        fMixturetype: data.fMixturetype, //  沥青混合料类型
        warningLevel: "", // 预警等级
        fCloseoperation: "", //闭合状态
        page: data.page, // 当前页码
        pageSize: data.pageSize, // 每页显示条数
      };
      getAsphaltRecipeLists(sc)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.listLoading = false;
            that.tableData = res.data.pageInfo.list;
            this.queryCriteriaData = res.data.pageInfo; //分页信息
            this.navigatepageNums =
              this.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    yj_viewForm() {
      var row = this.rowInfo;
      if (row != null) {
        var id = row.fId;
        this.fId = row.fId;
        this.dialogEditVisible = true;
        this.loadingEditDialog = true;
        getAsphaltRecipeDetail({ fId: id }).then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false;
            this.formData = res.data.asphaltRecipe;
            (this.formData.recordfiles = []), // 删除文件id集合
              (this.formData.fCompanyid = this.getList.fCompanyid);
            this.formData.fCompanyname = this.showName;

            this.fSourcefileList = res.data.fileList; // 附件
          } else {
            this.msgTip = "获取详情接口报错:" + res.msg;
            this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
            this.showMsgBox = true;
          }
        });
      } else {
        this.msgTip = "请先选择需要查看的数据";
        this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
        this.showMsgBox = true;
      }
    },
    yj_saveForm(num) {
      if (num == 0) {
        if (this.publicTable == true) {
          if (
            this.$refs.publicForm.submitForm() &&
            this.$refs.publicForm0.submitForm() &&
            this.$refs.publicForm1.submitForm() &&
            this.$refs.publicForm2.submitForm()
          ) {
            this.formData.fCompanyid = this.userInfo.companyId;
            this.formData.fCompanyname = this.userInfo.companyName;
            saveAsphaltRecipe(this.formData).then((res) => {
              if (res.errcode == 0) {
                this.yj_searchForm(this.getList);
                this.dialogEditVisible = false;
                // this.$message.success("新增成功");
              } else {
                this.msgTip = "新增失败:" + res.msg;
                this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
                this.showMsgBox = true;
              }
            });
          } else {
            this.msgTip = "请把信息填写完整！";
            this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
            this.showMsgBox = true;
          }
        } else {
          console.log(123);
        }
      } else if (num == 1) {
        console.log("级配保存");
        var data = {
          userId: this.userInfo.userId, // 当前登录用户id
          userName: this.userInfo.realName, // 当前登录用户名
          fCompanyid: this.userInfo.companyId, // 当前登录用户公司id
          fCompanyname: this.userInfo.companyName, // 当前登录用户公司name
          fId: this.fId, // 配方fid
          sieveList: this.sieveList,
        };
        saveAsphaltRecipeSieve(data).then((res) => {
          if (res.errcode == 0) {
            this.yj_searchForm(this.getList);
            this.dialogEditVisible = false;
            // this.$message.success("新增级配成功");
          } else {
            this.msgTip = "新增级配失败:" + res.msg;
            this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
            this.showMsgBox = true;
          }
        });
      }
    },

    getAsphaltRecipeListByCompanyId(id) {
      var data = {
        fCompanyid: id,
      };
      this.liqhDataList = [];
      getAsphaltRecipeListByCompanyId(data)
        .then((res) => {
          if (res.errcode == 0) {
            var arr = res.data.asphaltRecipeList;
            this.liqhDataList = [
              {
                fItemName: "所有沥青混合料类型",
                fItemValue: "",
              },
            ];
            arr.map((item) => {
              this.liqhDataList.push({
                fItemName: item.fMixturetype,
                fItemValue: item.fMixturetype,
              });
            });
          } else {
            this.msgTip = res.msg;
            this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
            this.showMsgBox = true;
            // this.$message.error(res.msg);
            // return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },

    selectChange(value, index, prop) {
      // 下拉框改变
      console.log("index", index);
      let itemvalue = null;
      if (prop == "fPitchnum") {
        for (let index = 0; index < this.asphaltNoList.length; index++) {
          const element = this.asphaltNoList[index];
          if (value == element.fItemname) {
            itemvalue = element.fItemvalue.split("-");
          }
        }

        this.formData.fTemperatureupper = itemvalue[1];
        this.formData.fTemperaturelower = itemvalue[0];
      }
    },
    // 获取字典项
    dictionaryItem(id, num) {
      getDictionaryTree({ fItemcode: id })
        .then((res) => {
          if (res.errcode == 0) {
            if (num == 1) {
              this.asphaltNoList = res.data.baseDataitemdetailList;
            }

            res.data.baseDataitemdetailList.map((item) => {
              if (num == 0) {
                this.formObj[2].options.push({
                  value: item.fItemname,
                  label: item.fItemname,
                });
              } else if (num == 1) {
                this.formObj[4].options.push({
                  value: item.fItemname,
                  label: item.fItemname,
                });
              }
            });
          } else {
            this.msgTip = "获取字典项失败:" + res.msg;
            this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
            this.showMsgBox = true;
          }
        })
        .catch(() => {
          console.log("获取字典项失败");
        });
    },

    inputValue(val, table, label) {
      if (label == "fSieveupper" || label == "fSievelower") {
        table.map((item) => {
          if (
            item.fSieveupper != null &&
            item.fSieveupper != "" &&
            item.fSievelower != null &&
            item.fSievelower != ""
          ) {
            item.fSievemiddle =
              (item.fSieveupper - 0 + (item.fSievelower - 0)) / 2;
          } else {
            item.fSievemiddle = "";
          }
        });
      }
      this.sieveList = table;
    },

    // 删除
    rowDelete(row) {
      if (row.fId != "" && row.fId != null) {
        // if (row.fStatus == "未提交") {
        this.msgTip = "此操作将永久删除该数据, 是否继续?";
        this.msgType = 2; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
        this.showMsgBox = true;
        this.titelName = "删除";
        // } else {
        //   this.msgTip = '请选择状态为"未提交"的数据！';
        //   this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
        //   this.showMsgBox = true;
        //   // this.$MessageBox.alertConfirmReminder('请选择状态为"未提交"的数据！');
        // }
      } else {
        this.msgTip = "请先选中要删除的数据！";
        this.msgType = 1; // 0 带功能确定  1 无功能确定  2 带功能确定、取消
        this.showMsgBox = true;
        // this.$MessageBox.alertConfirmReminder("请先选中要删除的数据！");
      }
    },
    delteFile(file) {
      // console.log(file, this.fSourcefileList);
      for (let index = 0; index < this.fSourcefileList.length; index++) {
        if (file.uid == this.fSourcefileList[index].uid) {
          if (this.fSourcefileList[index].atta == undefined) {
            this.formData.recordfiles.push({
              fId: this.fSourcefileList[index].fId,
            });
          } else {
            this.formData.recordfiles.push({
              fId: this.fSourcefileList[index].atta.fId,
            });
          }
          this.fSourcefileList.splice(index, 1);
        }
      }
    },
    // 公共弹框是否显示
    loadingShow(e) {
      this.loadingEditDialog = e;
    },
    // 获取拌合机
    getbhjDataMethods(data) {
      getMachineListByStationId({ stationId: data })
        .then((res) => {
          if (res.errcode == 0) {
            var arr = res.data.stationmachineList;

            this.bhjDataList = [
              {
                fItemName: "所有拌和机",
                fItemValue: "",
              },
            ];
            arr.map((item) => {
              this.bhjDataList.push({
                fItemName: item.fMachinename,
                fItemValue: item.fMachineid,
              });
            });
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },

    selectTime(e) {
      if (e[0] != "" && e[1] != "") {
        this.getList.startDates = e[0] + " " + "00:00:00"; // 开始时间
        this.getList.endDates = e[1] + " " + "23:59:59"; // 截至时间
        this.xlsxName = e[0] + "至" + e[1] + "混凝土拌和站记录数据";
      } else {
        this.getList.startDates = ""; // 开始时间
        this.getList.endDates = ""; // 截至时间
        this.xlsxName = "混凝土拌和站记录数据";
      }
      this.yj_searchForm(this.getList);
    },
    //
    getDate() {
      if (JSON.parse(sessionStorage.getItem("GxEmbedded_pitchManage_getLists"))) {
        var getList = JSON.parse(
          sessionStorage.getItem("GxEmbedded_pitchManage_getLists")
        );
        this.getList = getList;
        this.getList.page = 1; // 当前页码
        this.getList.pageSize = 15; // 每页显示条数
        if (getList.fprojectid != "") {
          this.getTender(getList.fprojectid);
          this.falgId = getList.fprojectid;
        }
        if (getList.fCompanyid != "" && getList.fCompanyid != null) {
          this.falgId = getList.fCompanyid;
        }

        if (getList.stationId != "" && getList.stationId != null) {
          this.getbhjDataMethods(getList.stationId);
        }
        this.yj_searchForm(this.getList);
        this.timeDuring = [this.getList.startDates, this.getList.endDates];
        this.xlsxName =
          this.getList.startDates +
          "至" +
          this.getList.endDates +
          "沥青拌和站记录数据";
      } else {
        this.getList.startDates = this.common.getDay(-90) + " " + "00:00:00"; // 开始时间
        this.getList.endDates = this.common.getDay(0) + " " + "23:59:59"; // 截至时间
        this.getList.fprojectid = this.projectsObj[1].fItemValue;

        this.getTender(this.getList.fprojectid);
        this.xlsxName =
          this.common.getDay(-90) +
          "至" +
          this.common.getDay(0) +
          " " +
          "23:59:59" +
          "水稳拌和站记录数据";

        this.timeDuring = [
          this.common.getDay(-90) + " " + "00:00:00",
          this.common.getDay(0) + " " + "23:59:59",
        ];
        this.yj_searchForm(this.getList);
      }
    },
    selectionChange() {},
    // 排序方法
    sortChange() {},
  },
};
</script>

<style scoped lang="less">
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.jpbox {
  height: 100%;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  // overflow-y: auto;
  // display: flex;
  // flex-direction: column;
}

.baseTitle {
  /* border: 1px solid #0c204d; */
  border-bottom: 1px solid #0c204d;
  width: 100%;
  height: 30px;
  line-height: 30px;
  position: relative;
  padding-left: 15px;
}

.baseTitle::after {
  display: block;
  content: "";
  height: 30px;
  width: 5px;
  position: absolute;
  left: 0;
  top: 0;
  background: #0c204d;
}

.mixProportion /deep/ .el-form-item__content {
  margin-left: 180px !important;
}
.fillableBox {
  display: flex;
}
.JpList {
  width: 250px;
  height: 100%;
  border: 1px solid #ccc;
  overflow-y: auto;
  div {
    width: 100%;
    height: 20px;
    line-height: 20px;
    border-bottom: 1px solid #ccc;
    text-align: center;
    background: #fff;
    color: #000;
  }
  .JpSieveListBox {
    width: 100%;
    height: 20px;
    line-height: 20px;
    border-bottom: 1px solid #ccc;
    text-align: center;
    background: #fff;
    color: #000;
  }
  .JpSieveListBox2 {
    background: #1559ba;
    color: #fff;
  }
}
.JpDetails {
  width: calc(100% - 250px);
  height: 100%;
}
.fillableBox /deep/ .el-table .cell {
  padding: 0 !important;
}

.fillableBox /deep/ .el-input__inner {
  border: none;
  height: 31px !important;
  padding: 0 !important;
  text-align: center;
}

.mixproportionForm /deep/ .el-select {
  width: 100% !important;
}

.OilStoneRate /deep/ .el-select {
  width: 100% !important;
}

.OilStoneRate /deep/ .el-form-item__content {
  margin-left: 95px !important;
}

#mixProportionBox /deep/ .el-collapse-item__content {
  padding-bottom: 10px !important;
}

.OilStoneRate /deep/ .el-col-8 {
  height: 30px;
  width: 33.3%;
}

.selectCondition /deep/ .el-select {
  width: 100px !important;
}

.selectCondition /deep/ .el-input__inner {
  width: 100px !important;
  height: 30px !important;
}
</style>
